//
//  ZipToolApp.swift
//  ZipTool
//
//  Created by jerry on 2025/8/15.
//

import SwiftUI

@main
struct ZipToolApp: App {
    @StateObject private var appSettings = AppSettings()
    
    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(appSettings)
        }
        .commands {
            CommandMenu("文件") {
                Button("打开压缩包...") {
                    NotificationCenter.default.post(name: .openArchive, object: nil)
                }
                .keyboardShortcut("O", modifiers: [.command])
                
                Button("新建压缩包...") {
                    NotificationCenter.default.post(name: .newArchive, object: nil)
                }
                .keyboardShortcut("N", modifiers: [.command])
            }
            
            CommandGroup(replacing: .appSettings) {
                Button("偏好设置...") {
                    NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
                }
                .keyboardShortcut(",")
            }
        }
        
        Settings {
            SettingsView(settings: appSettings)
                .frame(width: 400, height: 300)
        }
    }
}
